#pragma once

#include <boost/signals2/signal.hpp>




namespace boostext
{
	/**
	 * This class is a light wrapper around boost::signal  that only
	 * enables connecting / disconnecting to a signal, but not emitting.
	 * This way a public member: signal<boost::signal<...>> blub can be
	 * created and everyone can conventiantly connect and disconnect to/from
	 * the signal.
	 */
	template <typename Signal_t>
	class connector
	{
	private:

		Signal_t&   m_signal;

	public:

		connector(Signal_t& s) : m_signal(s) {}


		template <typename SlotFunction>
		typename boost::signals2::connection connect(SlotFunction f) { return m_signal.connect(f); }

		template <typename SlotFunction>
		void disconnect(SlotFunction f) { return m_signal.disconnect(f); }
	};
	///////////////////////////////////////////////////////////////////////////////////////////////




	/**
	 * This combiner takes a sequence of bool iterators and
	 * returns false, when any of them is false. Otherwise it
	 * returns true;
	 */
	struct negative_combiner
	{
		typedef bool result_type;

		template <typename InputIterator>
		bool operator()(InputIterator first, InputIterator last) const
		{
			if(first == last)
				return true;

			while(first != last)
			{
				if(*first == false)
					return false;

				++first;
			}

			return true;
		}
	};
	///////////////////////////////////////////////////////////////////////////////////////////////
}
///////////////////////////////////////////////////////////////////////////////////////////////////
